package drone.basis.util;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

public class MailUtil {

	public static String[] tos = new String[] { "wangpuxia@etonpay.com", "826566016@qq.com" };

	public static void sendEmail(String[] to, String subject, String context) {
		try {
			SimpleEmail email = new SimpleEmail();
			email.setHostName("smtp.qq.com");
			email.setAuthentication("7332962@qq.com", "*****");
			email.setCharset("utf-8");
			email.setFrom("7332962@qq.com");
			for (int i = 0; i < to.length; i++) {
				email.addTo(to[i]);
			}
			email.setSubject(subject);
			email.setMsg(context);
			email.send();
			System.out.println("邮件发送成功！");
		} catch (EmailException e) {
			System.out.println("邮件发送不成功！");
		}
	}

	public static void main(String[] args) {
		MailUtil.sendEmail(tos, "警告", "test");
	}
}
